// pages/page1/page1.js
const publicParams = require("../../utils/publicParams");

Page({
    /**
     * 页面的初始数据
     */
    data: {
        globalQiniuImgUrl: publicParams.baseImgUrl,
        bannerList: [],
        xingchengList: []
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onShow: function(options) {
        let self = this;
        console.log(12112)
        wx.getSetting({
            success(res) {
                console.log("打印结果：",res)
              if (!res.authSetting['scope.userInfo']) {
                wx.navigateTo({
                    url: '/pages/authorize/authorize',
                })
              } else {
                self.getBannerList();
                self.getRouteList();
              }
            }
        })
        
    },
    /** 获取轮播列表 */
    getBannerList() {
        wx.$http.post(wx.$api.fetchBannerList, { pos: 1 }).then(res => {
                this.setData({
                    bannerList: res
                })
            })
            .catch(err => {
                console.log(err);
            })
    },
    // 获取线路攻略
    getRouteList() {
        wx.$http.post(wx.$api.fetchStrategyList, { limit: 60, page: 1 }).then(res => {
                console.log(res)
                this.setData({
                    xingchengList: res.data || []
                })
            })
            .catch(() => {})
    }
})